package com.hamishmedlin.d64pw;

import java.util.HashMap;
import java.util.Map;

public class Fields {

	private int nextmap = 1;
	private int gameskill = 0;
	private Map<String,Boolean> checked;
	private int clip = 50,shell = 0,misl = 0,cell = 0;
	private int maxClip = 200,maxShell = 50,maxRocket = 50,maxCell = 300;
	private int health = 100,armor = 0;
	private int armorType = 0;
	private boolean backpack;
	
	public Fields(){
		checked = new HashMap<String,Boolean>(10);
		
		for(int i = 0;i < QGlobals.weaponControlForIndex.length;i++){
			checked.put(QGlobals.weaponControlForIndex[i], false);
		}

		checked.put(QGlobals.WEAPON_FIST, true);
        checked.put(QGlobals.WEAPON_PISTOL, true);
		checked.put(QGlobals.ARTIFACT_FAST, false);
		checked.put(QGlobals.ARTIFACT_DOUBLE, false);
		checked.put(QGlobals.ARTIFACT_TRIPLE, false);
		
		backpack = false;
	}

	public boolean getBackback(){
		return backpack;
	}
	
	public void setBackpack(boolean input){
		this.backpack = input;
		if(backpack){
			maxClip = 400;
			maxShell = 100;
			maxRocket = 100;
			maxCell = 600;
		}else{
			maxClip = 200;
			maxShell = 50;
			maxRocket = 50;
			maxCell = 300;
		}
		
	}
	public void setCells(int input){
		if(input <= maxCell){
			this.cell = input;
		}else{
			this.cell = 0;
		}
	}
	
	public int getCells(){
		return this.cell;
	}
	
	public void setRockets(int input){
		if(input <= maxRocket){
			this.misl = input;
		}else{
			this.misl = 0;
		}
	}
	
	public int getRockets(){
		return this.misl;
	}
	
	public void setShells(int input){
		if(input <= maxShell){
			this.shell = input;
		}else{
			this.shell = 0;
		}
	}
	
	public int getShells(){
		return this.shell;
	}
	
	public void setClip(int input){
		if(input <= maxClip){
			this.clip = input;
		}else{
			this.clip = 0;
		}
	}
	
	public int getClip(){
		return this.clip;
	}
	
	public boolean getChecked(String key){
		try{
			return checked.get(key).booleanValue();
		}catch(NullPointerException e){
			return false;
		}
	}
	
	public Map<String,Boolean> getCheckedMap(){
		return checked;
	}
	
	public void setChecked(String key, boolean value){
		checked.put(key, value);
	}
	
	public int getNextMap(){
		return nextmap;
	}
	
	public int getGameSkill(){
		return gameskill;
	}
	
	public void setGameSkill(int gameskill){
		switch(gameskill){
			case 0:
			case 1:
			case 2:
			case 3:
				this.gameskill = gameskill;
				break;
			default:
				this.gameskill = 1;
		}
	}
	
	public void setNextMap(int nextmap){
		if(nextmap > 32){
			this.nextmap = 32;
		}else if(nextmap < 1){
			this.nextmap = 1;
		}else{
			this.nextmap = nextmap;
		}
	}

	public int getMaxClip() {
		return maxClip;
	}
	
	public int getMaxShell() {
		return maxShell;
	}

	public int getMaxRocket() {
		return maxRocket;
	}

	public int getMaxCell() {
		return maxCell;
	}

	public int getHealth() {
		return health;
	}

	public void setHealth(int health) {
		if(health > 200 || health < 1){
			health = 100;
		}
		this.health = health;
	}

	public int getArmor() {
		return armor;
	}

	public void setArmor(int armor) {
		if(armor > 200){
			armor = 0;
		}
		this.armor = armor;
	}

	public int getArmorType() {
		return armorType;
	}

	public void setArmorType(int armorType) {
		if(armorType > 3 || armorType < 0){
			armorType = 0;			
		}		
		this.armorType = armorType;		
	}
}
